package com.easy.controller;


import com.easy.bean.Room_type;
import com.easy.service.Room_typeService;
import com.easy.util.Page;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin//允许跨域访问
@RequestMapping("room_type")
public class Room_typeController {
    @Autowired
    Room_typeService room_typeService;

    @PostMapping
    public Result add(@RequestBody Room_type room_type) {
        Object obj = room_typeService.add(room_type);
        return Result.success(obj);
    }

    @PutMapping
    public Result edit(@RequestBody Room_type room_type) {
        Object obj = room_typeService.edit(room_type);
        return Result.success(obj);
    }

    @DeleteMapping("{roomNumber}")
    public Result del(@PathVariable(name = "roomNumber") String roomNumber) {
        Object obj = room_typeService.del(roomNumber);
        return Result.success(obj);
    }

    @GetMapping("{roomNumber}")
    public Result one(@PathVariable(name = "roomNumber") String roomNumber) {
        Object obj = room_typeService.one(roomNumber);
        return Result.success(obj);
    }

    @GetMapping("all")
    public Result all(Room_type room_type) {
        Object obj = room_typeService.all(room_type);
        return Result.success(obj);
    }

    @GetMapping("page")
    public Result page(Page page, Room_type room_type) {
        room_typeService.page(page, room_type);
        return Result.success(page);
    }
}
